home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / c-tools / tds / convsrc / barfly2msg.asm < prev    next >
Encoding:
Assembly Source File  |  1995-11-01  |  3.9 KB  |  268 lines

  1. ; Barfly2Msg.asm
  2.  
  3.         INCDIR    devpac:include31
  4.  
  5.         INCLUDE    exec/libraries.i
  6.         INCLUDE    exec/types.i
  7.         INCLUDE    exec/exec_lib.i
  8.         INCLUDE    dos/dos_lib.i
  9.  
  10.  
  11.  
  12.         SECTION    Kode,CODE
  13.  
  14. Begin:        movem.l    d1-a6,-(SP)
  15.         move.l    SP,_SYSSP
  16.  
  17.         bsr.w    OpenDOS
  18.  
  19.         bsr.b    Parse
  20.  
  21. ExitToDOS:    move.l    _SYSSP,SP
  22.  
  23.         bsr.w    CloseDOS
  24.  
  25.         movem.l    (SP)+,d1-a6
  26.         moveq    #0,d0
  27.         rts
  28.  
  29.  
  30. StrCmp:
  31. .next        move.b    (a1)+,d0
  32.         beq.b    .equal
  33.         cmp.b    (a0)+,d0
  34.         beq.b    .next
  35.         moveq    #-1,d0
  36.         rts
  37. .equal        moveq    #0,d0
  38.         rts
  39.  
  40. Parse:        move.l    _DOSBase,a6
  41.  
  42.         move.l    _InputHandle,d1
  43.         move.l    #ReadBuffer,d2
  44.         move.l    #256-1,d3
  45.         jsr    _LVOFGets(a6)
  46.         tst.l    d0
  47.         beq.w    .finished
  48.  
  49.         lea    ReadBuffer,a0
  50.         lea    .t_error(PC),a1
  51.         bsr.b    StrCmp
  52.         beq.b    .error
  53.  
  54.         lea    ReadBuffer,a0
  55.         lea    .t_warning(PC),a1
  56.         bsr.b    StrCmp
  57.         beq.b    .warning
  58.  
  59.         lea    ReadBuffer,a0
  60.         lea    .t_error3(PC),a1
  61.         bsr.b    StrCmp
  62.         beq.b    .error
  63.  
  64.         lea    ReadBuffer,a0
  65.         lea    .t_warning3(PC),a1
  66.         bsr.b    StrCmp
  67.         beq.b    .warning
  68.  
  69.         bra.b    Parse
  70.  
  71. .error        move.b    #'E',d7
  72.         bra.b    .common
  73.  
  74. .warning    move.b    #'W',d7
  75.  
  76. .common        bsr.w    .copylinenumber
  77.         addq.w    #4,a0        ;skip ' in '
  78.         move.l    a0,a2
  79.  
  80.         lea    .t_file(PC),a1
  81.         bsr    StrCmp
  82.         beq.b    .file
  83.  
  84.         move.l    a2,a0
  85.         lea    .t_macro(PC),a1
  86.         bsr    StrCmp
  87.         beq.b    .macro
  88.  
  89.         move.l    a2,a0
  90.         bra.b    .file
  91.  
  92. .macro        move.l    _InputHandle,d1
  93.         move.l    #ReadBuffer,d2
  94.         move.l    #256-1,d3
  95.         jsr    _LVOFGets(a6)
  96.         tst.l    d0
  97.         beq.w    .finished
  98.  
  99.         lea    ReadBuffer,a0
  100.         lea    .t_macroerror(PC),a1
  101.         bsr    StrCmp
  102.         bne.w    Parse
  103.  
  104.         beq.b    .common
  105.  
  106. .file        move.l    a0,a2
  107.         cmp.b    #"`",(a2)
  108.         bne.b    .find
  109.         addq.w    #1,a2
  110.         move.l    a2,a0
  111.  
  112. .find        move.b    (a2),d0
  113.         beq.b    .eol
  114.         cmp.b    #10,d0
  115.         beq.b    .eol
  116.         addq.w    #1,a2
  117.         bra.b    .find
  118. .eol        clr.b    (a2)
  119.         clr.b    -(a2)
  120.         cmp.b    #"'",-1(a2)
  121.         bne.b    .sjov
  122.         clr.b    -(a2)
  123. .sjov        move.l    a0,a2
  124.  
  125.  
  126.         moveq    #'<',d2
  127.         move.l    _OutputHandle,d1
  128.         jsr    _LVOFPutC(a6)
  129.  
  130.         move.l    _OutputHandle,d1
  131.         move.l    a2,d2
  132.         jsr    _LVOFPuts(a6)
  133.  
  134.         moveq    #'>',d2
  135.         move.l    _OutputHandle,d1
  136.         jsr    _LVOFPutC(a6)
  137.  
  138.         move.l    _OutputHandle,d1
  139.         move.l    #Line,d2
  140.         jsr    _LVOFPuts(a6)
  141.  
  142.         move.l    _InputHandle,d1
  143.         move.l    #Line,d2
  144.         move.l    #256-1,d3
  145.         jsr    _LVOFGets(a6)
  146.         tst.l    d0
  147.         beq.w    .finished
  148.  
  149.         move.l    _InputHandle,d1
  150.         move.l    #ReadBuffer,d2
  151.         move.l    #256-1,d3
  152.         jsr    _LVOFGets(a6)
  153.         tst.l    d0
  154.         beq.w    .finished
  155.  
  156.         move.l    d7,d2
  157.         move.l    _OutputHandle,d1
  158.         jsr    _LVOFPutC(a6)
  159.  
  160.         moveq    #' ',d2
  161.         move.l    _OutputHandle,d1
  162.         jsr    _LVOFPutC(a6)
  163.  
  164.         moveq    #'<',d2
  165.         move.l    _OutputHandle,d1
  166.         jsr    _LVOFPutC(a6)
  167.  
  168.         cmp.b    #'W',d7
  169.         beq.b    .add_w
  170.         move.l    #.t_error2,d2
  171.         bra.b    .add_e
  172. .add_w        move.l    #.t_warning2,d2
  173. .add_e        move.l    _OutputHandle,d1
  174.         jsr    _LVOFPuts(a6)
  175.  
  176.         lea    Line,a0
  177. .find_colon    cmp.b    #':',(a0)+
  178.         bne.b    .find_colon
  179.         addq.w    #1,a0
  180.         move.l    a0,a2
  181. .find_eol    cmp.b    #10,(a2)+
  182.         bne.b    .find_eol
  183.         clr.b    -(a2)
  184.  
  185.         move.l    a0,d2
  186.         move.l    _OutputHandle,d1
  187.         jsr    _LVOFPuts(a6)
  188.  
  189.         moveq    #'>',d2
  190.         move.l    _OutputHandle,d1
  191.         jsr    _LVOFPutC(a6)
  192.  
  193.         moveq    #10,d2
  194.         move.l    _OutputHandle,d1
  195.         jsr    _LVOFPutC(a6)
  196.  
  197.         bra.w    Parse
  198.  
  199. .finished    jsr    _LVOFlush(a6)
  200.         rts
  201.  
  202. .copylinenumber    lea    Line,a1
  203.         move.b    #' ',(a1)+
  204. .again        cmp.b    #' ',(a0)
  205.         beq.b    .done
  206.         move.b    (a0)+,(a1)+
  207.         bra.b    .again
  208. .done        move.b    #' ',(a1)+
  209.         clr.b    (a1)+
  210.         rts
  211.  
  212. .t_error2    dc.b    "Error: ",0
  213. .t_warning2    dc.b    "Warning: ",0
  214. .t_error    dc.b    "Error in Line ",0
  215. .t_error3    dc.b    "Error, Line ",0
  216. .t_warning    dc.b    "Warning in Line ",0
  217. .t_warning3    dc.b    "Warning, Line ",0
  218. .t_file        dc.b    "File `",0
  219. .t_macro    dc.b    "Macro `",0
  220. .t_macroerror    dc.b    "Macro is located at Line ",0
  221. .format        dc.b    "%d ",0
  222.         EVEN
  223.  
  224.  
  225. OpenDOS:    move.l    4.w,a6
  226.         lea    .dosname(PC),a1
  227.         moveq    #36,d0
  228.         jsr    _LVOOpenLibrary(a6)
  229.         move.l    d0,_DOSBase
  230.         beq.w    ExitToDOS
  231.         move.l    d0,a6
  232.  
  233.         jsr    _LVOInput(a6)
  234.         move.l    d0,_InputHandle
  235.  
  236.         jsr    _LVOOutput(a6)
  237.         move.l    d0,_OutputHandle
  238.         rts
  239.  
  240. .dosname    dc.b    "dos.library",0
  241.         EVEN
  242.  
  243. CloseDOS:    move.l    4.w,a6
  244.         move.l    _DOSBase,d0
  245.         beq.b    .no_dos
  246.         move.l    d0,a1
  247.         jsr    _LVOCloseLibrary(a6)
  248. .no_dos        rts
  249.  
  250. .version    dc.b     "$VER: Barfly2Msg 1.00 (08.11.94)"
  251.  
  252.         SECTION    DenFedeBuffer,BSS
  253.  
  254. _SYSSP:        DS.L    1
  255. _DOSBase:    DS.L    1
  256. _InputHandle:    DS.L    1
  257. _OutputHandle:    DS.L    1
  258.  
  259. ReadBuffer:    DS.B    256
  260. Line:        DS.B    256
  261.  
  262.  
  263.  
  264.  
  265.  
  266.         END
  267.  
  268.